home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / standard / math.z / math
Encoding:
Text File  |  2002-10-03  |  30.2 KB  |  541 lines

  1. MATH(3M)                                               Last changed: 2-2-99
  2.  
  3.  
  4. NNAAMMEE
  5.      mmaatthh - introduction to mathematical library functions
  6.  
  7. IIMMPPLLEEMMEENNTTAATTIIOONN
  8.      IRIX systems
  9.  
  10. DDEESSCCRRIIPPTTIIOONN
  11.      These functions constitute the C math library lliibbmm.  There are four
  12.      versions of the math library:  lliibbmm..aa,, lliibbmmxx..aa,, lliibbmm4433..aa, and
  13.      lliibbffaassttmm..aa
  14.  
  15.      The first, lliibbmm..aa,, contains routines implemented in 1994 that use
  16.      algorithms which take advantage of the MIPS architecture and include
  17.      many routines for the ffllooaatt data type.
  18.  
  19.      For the --6644 and --nn3322 versions of lliibbmm..aa,, a second version of the math
  20.      library, lliibbmmxx..aa,, contains functions which give identical results to
  21.      those in lliibbmm..aa, but which use System V error handling.
  22.  
  23.      See mmaatthheerrrr(3M) for a description of error handling for lliibbmmxx..aa
  24.      functions.
  25.  
  26.      The third version of the math library, lliibbmm4433..aa, contains routines all
  27.      based on the original codes in the 4.3BSD release. The difference
  28.      between the error bounds for lliibbmm..aa and lliibbmm4433..aa is typically around 1
  29.      unit in the last place (ULP), whereas the performance difference may
  30.      be a factor of two or more.
  31.  
  32.      The link editor searches this library under the --llmm, --llmmxx, or --llmm4433
  33.      option.  Declarations for these functions may be obtained from the
  34.      include file <<mmaatthh..hh>>.
  35.  
  36.      The fourth library, lliibbffaassttmm..aa,, contains faster, lower-precision
  37.      versions of various routines from lliibbmm..aa.
  38.  
  39.    LLiisstt ooff ffuunnccttiioonnss
  40.      Error bounds (in ULPs) in the final two columns in this table apply
  41.      only to the --6644 and --nn3322 versions of lliibbmm..aa and lliibbmmxx..aa, The error
  42.      bound sometimes applies only to the primary range.
  43.  
  44.   ------------------------------------------------------------------------
  45.   Name       Man page   Description                          lliibbmm..aa lliibbmm4433..aa
  46.   ------------------------------------------------------------------------
  47.   aaccooss       ssiinn(3M)    inverse trigonometric function         2       3
  48.   aaccoossff      ssiinn(3M)    inverse trigonometric function         1
  49.   aaccoosshh      aassiinnhh(3M)  inverse hyperbolic function            3       3
  50.   aassiinn       ssiinn(3M)    inverse trigonometric function         2       3
  51.   aassiinnff      ssiinn(3M)    inverse trigonometric function         1
  52.   aassiinnhh      aassiinnhh(3M)  inverse hyperbolic function            3       3
  53.   aattaann       ssiinn(3M)    inverse trigonometric function        1.5      1
  54.   aattaannff      ssiinn(3M)    inverse trigonometric function         1
  55.   aattaannhh      aassiinnhh(3M)  inverse hyperbolic function            3       3
  56.   aattaann22      ssiinn(3M)    inverse trigonometric function         2       2
  57.   aattaann22ff     ssiinn(3M)    inverse trigonometric function         1
  58.   ccaabbss       hhyyppoott(3M)  complex absolute value                 1       1
  59.   aabbssff       hhyyppoott(3M)  complex absolute value                 1
  60.   ccbbrrtt       ssqqrrtt(3M)   cube root                              1       1
  61.   cceeiill       fflloooorr(3M)  integer no less than                   0       0
  62.   cceeiillff      fflloooorr(3M)  integer no less than                   0       0
  63.   ccooppyyssiiggnn   iieeeeee(3M)   copy sign bit                          0       0
  64.   ccooss        ssiinn(3M)    trigonometric function                 2       1
  65.   ccoossff       ssiinn(3M)    trigonometric function                 1
  66.   ccoosshh       ssiinnhh(3M)   hyperbolic function                    2       3
  67.   ccoosshhff      ssiinnhh(3M)   hyperbolic function                    1
  68.   ddrreemm       iieeeeee(3M)   remainder                              0       0
  69.   eerrff        eerrff(3M)    error function                         1       ?
  70.   eerrffcc       eerrff(3M)    complementary error function           4       ?
  71.   eexxpp        eexxpp(3M)    exponential                            1       1
  72.   eexxppff       eexxpp(3M)    exponential                            1
  73.   eexxppmm11      eexxpp(3M)    exp(x)-1                               1       1
  74.   eexxppmm11ff     eexxpp(3M)    exp(x) - 1                             1
  75.   ffaabbss       fflloooorr(3M)  absolute value                         0       0
  76.   ffaabbssff      fflloooorr(3M)  absolute value                         0       0
  77.   ffiinniittee     iieeeeee(3M)   floating point arithmetic            (N/A)
  78.   fflloooorr      fflloooorr(3M)  integer no greater than                0       0
  79.   fflloooorrff     fflloooorr(3M)  integer no greater than                0       0
  80.   ffmmoodd       fflloooorr(3M)  remainder function                     0
  81.   ffmmooddff      fflloooorr(3M)  remainder function                     0
  82.   hhyyppoott      hhyyppoott(3M)  Euclidean distance                     1       1
  83.   hhyyppoottff     hhyyppoott(3M)  Euclidean distance                     1       1
  84.   jj00         jj00(3M)     bessel function                        ?       ?
  85.   jj11         jj00(3M)     bessel function                        ?       ?
  86.   jjnn         jj00(3M)     bessel function                        ?       ?
  87.   llggaammmmaa     llggaammmmaa(3M) log gamma function                     ?       ?
  88.   lloogg        eexxpp(3M)    natural logarithm                      1       1
  89.   llooggff       eexxpp(3M)    natural logarithm                      1
  90.   llooggbb       iieeeeee(3M)   exponent extraction                    0       0
  91.   lloogg1100      eexxpp(3M)    logarithm to base 10                   2       3
  92.   lloogg1100ff     eexxpp(3M)    logarithm to base 10                  1.5
  93.   lloogg11pp      eexxpp(3M)    log(1+x)                               1       1
  94.   lloogg11ppff     eexxpp(3M)    log(1+x)                               1       1
  95.   ppooww        eexxpp(3M)    exponential  x**y                      2     60-500
  96.   ppoowwff       eexxpp(3M)    exponential x**y                       1
  97.   rriinntt       fflloooorr(3M)  round to nearest integer               0       0
  98.   ssiinn        ssiinn(3M)    trigonometric function                 2       1
  99.   ssiinnff       ssiinn(3M)    trigonometric function                 1
  100.   ssiinnhh       ssiinnhh(3M)   hyperbolic function                    2       3
  101.   ssiinnhhff      ssiinnhh(3M)   hyperbolic function                    1
  102.   ssqqrrtt       ssqqrrtt(3M)   square root                            1       1
  103.   ssqqrrttff      ssqqrrtt(3M)   square root                            1
  104.   ttaann        ssiinn(3M)    trigonometric function                 2       3
  105.   ttaannff       ssiinn(3M)    trigonometric function                 1
  106.   ttaannhh       ssiinnhh(3M)   hyperbolic function                    2       3
  107.   ttaannhhff      ssiinnhh(3M)   hyperbolic function                    1
  108.   ttrruunncc      fflloooorr(3M)  truncate to whole number               0       0
  109.   ttrruunnccff     fflloooorr(3M)  truncate to whole number               0       0
  110.   yy00         jj00(3M)     bessel function                        ?       ?
  111.   yy11         jj00(3M)     bessel function                        ?       ?
  112.   yynn         jj00(3M)     bessel function                        ?       ?
  113.   ------------------------------------------------------------------------
  114.  
  115.    VVeeccttoorr IInnttrriinnssiiccss
  116.      Beginning with IRIX 6.2, lliibbmm now supports the following vector
  117.      intrinsics:
  118.  
  119.      Single precision vector routines:
  120.  
  121.       vacosf( float *x, float *y, long count, long stridex, long stridey )
  122.       vasinf( float *x, float *y, long count, long stridex, long stridey )
  123.       vatanf( float *x, float *y, long count, long stridex, long stridey )
  124.       vcosf(  float *x, float *y, long count, long stridex, long stridey )
  125.       vexpf(  float *x, float *y, long count, long stridex, long stridey )
  126.       vlogf(  float *x, float *y, long count, long stridex, long stridey )
  127.       vlog10f( float *x, float *y, long count, long stridex, long stridey )
  128.       vsinf(  float *x, float *y, long count, long stridex, long stridey )
  129.       vsqrtf( float *x, float *y, long count, long stridex, long stridey )
  130.       vtanf(  float *x, float *y, long count, long stridex, long stridey )
  131.  
  132.      Double precision vector routines:
  133.  
  134.      vacos( double *x, double *y, long count, long stridex, long stridey )
  135.      vasin( double *x, double *y, long count, long stridex, long stridey )
  136.      vatan( double *x, double *y, long count, long stridex, long stridey )
  137.      vcos(  double *x, double *y, long count, long stridex, long stridey )
  138.      vexp(  double *x, double *y, long count, long stridex, long stridey )
  139.      vlog(  double *x, double *y, long count, long stridex, long stridey )
  140.      vlog10( double *x, double *y, long count, long stridex, long stridey )
  141.      vsin(  double *x, double *y, long count, long stridex, long stridey )
  142.      vsqrt( double *x, double *y, long count, long stridex, long stridey )
  143.      vtan(  double *x, double *y, long count, long stridex, long stridey )
  144.  
  145.      Input and output arrays for the above routines should either be
  146.      identical or non-overlapping.
  147.  
  148.      On MIPS4 processors, these routines are software-pipelined to take
  149.      advantage of the multiple execution units.  On that machine,
  150.      throughput is up to several times greater than by calling the scalar
  151.      intrinsics repeatedly.  On processors other than the MIPS4, these
  152.      routines are still available; although not software-pipelined on those
  153.      processors, they still eliminate considerable call overhead when they
  154.      can be used.  The vector routines do not support denormals on the
  155.      MIPS4 processors.
  156.  
  157.      The single precision vector routines can also be called by the names
  158.      vvffaaccooss, vvffaassiinn, etc.
  159.  
  160.    SSeemmaannttiiccss ooff tthheessee rroouuttiinneess
  161.                i=0, 1, ..., count-1:  y[i*stridey] = f(x[i*stridex])
  162.  
  163.                Example:
  164.  
  165.                ddoouubbllee xx[[1100000000]],, yy[[1100000000]];;
  166.  
  167.                ......
  168.  
  169.                     ffoorr ((ii==00;; ii<<11000000;; ii++++ ))
  170.                          yy[[22**ii]] == ssiinn((xx[[33**ii]]));;
  171.  
  172.                Transform (by hand) into
  173.  
  174.                     vvssiinn((xx,, yy,, 11000000,, 33,, 22));;
  175.  
  176.  
  177.      Vector and scalar routines may differ slightly; however, none of the
  178.      results differ from the mathematically correct result by more than 2
  179.      ULPs.  The vector square root routines are less accurate than the
  180.      hardware versions; vvssqqrrtt and vvssqqrrttff use the reciprocal square root
  181.      instruction and lose up to about 2 bits of accuracy.  vvssqqrrtt and vvffssqqrrtt
  182.      give correct answers for zero and infinite arguments.
  183.  
  184.    LLoonngg DDoouubbllee AArriitthhmmeettiicc
  185.      Long double arithmetic is supported by the compiler.  The
  186.      representation used is not IEEE compliant; long doubles are
  187.      represented on this system as the sum or difference of two doubles,
  188.      normalized so that the smaller double is <= .5 ULP of the larger.
  189.      This is equivalent to a 107 bit mantissa with an 11 bit biased
  190.      exponent (bias = 1023), and 1 sign bit.  In terms of decimal
  191.      precision, this is approximately 34 decimal digits.
  192.  
  193.      Long double constants are coded as double precision constants followed
  194.      by the letter 'l' (upper or lower case).  The largest (finite) long
  195.      double constant is 1.797693134862315807937289714053023e308L.
  196.  
  197.      The smallest long double precision constant is
  198.      4.940656458412465441765687928682213e-324L.
  199.  
  200.      Long doubles less than 1.805194375864829576069262081173746e-276L may
  201.      require a double denormal in their representation and therefore
  202.      contain less than 107 bits precision.
  203.  
  204.      Long double NaNs and (signed) infinities are supported by the
  205.      compiler.  Long double infinity is represented as the sum of a double
  206.      infinity and a double zero; similarly for NaNs.
  207.  
  208.      In Fortran, long doubles are denoted by the term REAL *16.
  209.  
  210.      In general, long double arithmetic operations (++,, --,, **,, //) are not
  211.      precisely rounded, but are accurate to approximately 3 ULPs.
  212.  
  213.      Long double arithmetic operations are done in software by MIPSpro
  214.      compilers; results of these operations may vary slightly from release
  215.      to release due to improvements in the algorithms which implement them.
  216.  
  217.      Long double operations on this system are only supported in  _r_o_u_n_d-
  218.      _t_o-_n_e_a_r_e_s_t rounding mode (the default).  The system must be in round-
  219.      to-nearest rounding mode when issuing long double arithmetic
  220.      operations or calling any of the long double functions; otherwise,
  221.      incorrect answers result.
  222.  
  223.    DDiiffffeerreenncceess bbeettwweeeenn --oo3322, --nn3322, --6644
  224.      At the IRIX 6.2 release, faster and more accurate algorithms were
  225.      implemented, and vector functions were added to the math library.  In
  226.      order to maintain numerical compatibility with older releases, these
  227.      changes were made only in the --nn3322 and --6644 versions of the library and
  228.      not in the --oo3322 version.  If there are differences in accuracy, this
  229.      document describes the behavior of the --nn3322 and --6644 versions of the
  230.      library.
  231.  
  232.      To take advantage of the new functions and algorithms, you need to
  233.      compile and link using either the --nn3322 or the --6644 option.
  234.  
  235.      The --oo3322 version of lliibbmmxx contains all routines present in the --nn3322
  236.      and --6644 versions of lliibbmmxx except the quad precision and vector
  237.      routines, and gives results identical to the --nn3322 and --6644 versions.
  238.  
  239. NNOOTTEESS
  240.      Users concerned with portability to other computer systems should note
  241.      that the long double and float versions of these functions are
  242.      optional according to the ANSI C Programming Language Specification
  243.      ISO/IEC 9899 : 1990 (E).
  244.  
  245.      Long double functions have been renamed to be compliant with the
  246.      ANSI-C standard; to be backward compatible, however, they may still be
  247.      called with the double precision function name prefixed with a qq.  The
  248.      exceptions are functions ffaabbssll and ffmmooddll, which may be called with
  249.      names qqaabbss and qqmmoodd.
  250.  
  251.      In 4.3BSD, distributed from the University of California in late 1985,
  252.      most of the foregoing functions come in two versions, one for the
  253.      double-precision "D" format in the DDEECC, VVAAXX--1111 family of computers,
  254.      another for double-precision arithmetic conforming to the IEEE
  255.      Standard 754 for Binary Floating-point Arithmetic.  The two versions
  256.      behave very similarly.  For instance, the programs are accurate to
  257.      within the numbers of ULPs tabulated above.  And the programs no
  258.      longer have the anomalies found in the older math library lliibbmm in
  259.      which incidents like the following had been reported:
  260.  
  261.      * ssqqrrtt((--11..00)) == 00..00 and lloogg((--11..00)) == --11..77ee3388
  262.  
  263.      ** ((ccooss((11..00ee--1111)) >> ccooss((00..00)) >> 11..00
  264.  
  265.      ** ppooww((xx,,11..00)) !!== xx when xx == 22..00,, 33..00,, 44..00,, ......,, 99..00
  266.  
  267.      * ppooww((--11..00,,11..00ee1100)) trapped on Integer Overflow
  268.  
  269.      * ssqqrrtt((11..00ee3300)) and ssqqrrtt((11..00ee--3300)) were very slow
  270.  
  271.      This machine conforms to the IEEE Standard 754 for Binary Floating-
  272.      point Arithmetic, to which only the notes for IEEE floating-point
  273.      apply and are included here.  See the notes regarding long double
  274.      precision below.
  275.  
  276.    IIEEEEEE SSTTAANNDDAARRDD 775544 FFllooaattiinngg--ppooiinntt AArriitthhmmeettiicc
  277.      This standard has become more widely adopted than any other design for
  278.      computer arithmetic.
  279.  
  280.      Properties of IEEE 754 Double-precision:
  281.  
  282.      * Wordsize: 64 bits, 8 bytes.  Radix: Binary.
  283.  
  284.      * Precision: 53 significant bits, roughly 16 significant decimals.  If
  285.        xx and xx'' are consecutive positive double-precision numbers (they
  286.        differ by 1 ULP), then
  287.  
  288.        11..11ee --1166 << 00..55****5533 << ((xx''--xx))//xx <<== 00..55****5522 << 22..33ee--1166
  289.  
  290.      * Range: Overflow threshold = 22..00****11002244 == 11..88ee330088
  291.  
  292.        Underflow threshold = 00..55****11002222 == 22..22ee --330088
  293.  
  294.        Overflow goes by default to a signed Infinity.
  295.  
  296.        Underflow is _G_r_a_d_u_a_l, rounding to the nearest integer multiple of
  297.        00..55****11007744 == 44..99ee --332244.
  298.  
  299.      * Zero is represented ambiguously as ++00, or --00.  Its sign transforms
  300.        correctly through multiplication or division, and is preserved by
  301.        addition of zeros with like signs; but xx--xx yields ++00 for every
  302.        finite _x.  The only operations that reveal zero's sign are division
  303.        by zero and ccooppyyssiiggnn((xx,,++__00)).  In particular, comparison ((xx >> yy,, xx >>==
  304.        yy, etc.)  cannot be affected by the sign of zero; but if finite xx ==
  305.        yy then IInnffiinniittyy == 11//((xx--yy)) !!== 11//((yy--xx)) == --IInnffiinniittyy.
  306.  
  307.      * Infinity is signed. It persists when added to itself or to any
  308.        finite number.  Its sign transforms correctly through multiplication
  309.        and division, and (finite)/+_ Infinity = +_0 (nonzero)/0 = +_ Infinity.
  310.        But IInnffiinniittyy -- IInnffiinniittyy, IInnffiinniittyy**00 and IInnffiinniittyy//IInnffiinniittyy are, like
  311.        0/0 and ssqqrrtt((--33)), invalid operations that produce NaN.
  312.  
  313.      * Reserved operands:  there are 22****5533--22 of them, all called NaN (_Not _a
  314.        _Number).  Some, called Signaling NaNs, trap any floating-point
  315.        operation performed upon them; they could be used to mark missing or
  316.        uninitialized values, or nonexistent elements of arrays.  The rest
  317.        are Quiet Nans; they are the default results of Invalid Operations,
  318.        and propagate through subsequent arithmetic operations.  If xx !!== xx
  319.        then x is NaN; every other predicate ((xx >> yy,, xx == yy,, xx << yy,, ......)) is
  320.        FALSE if NaN is involved.
  321.  
  322.        NOTE: Trichotomy is violated by NaN.
  323.  
  324.        Besides being FALSE, predicates that entail ordered comparison,
  325.        rather than mere (in)equality, signal Invalid Operation when NaN is
  326.        involved.
  327.  
  328.      * Rounding:  Every algebraic operation, (++,,--,, **,, //,, ssqqrrtt)) is rounded
  329.        by default to within half a ULP, and when the rounding error is
  330.        exactly half a ULP then the rounded value's least significant bit is
  331.        zero.  This kind of rounding is usually the best kind, sometimes
  332.        provably so; for instance, for every xx == 11..00,, 22..00,, 33..00,, 44..00,, ......,,
  333.        22..00****5522, we find ((xx//33..00))**33..00 ==== xx and ((xx//1100..00))**1100..00 ==== xx and ...
  334.        despite that both the quotients and the products have been rounded.
  335.        Only rounding like IEEE 754 can do that.  But no single kind of
  336.        rounding can be proved best for every circumstance, so IEEE 754
  337.        provides rounding towards zero or towards ++IInnffiinniittyy or towards
  338.        --IInnffiinniittyy at the programmer's option.
  339.  
  340.      * Exceptions:  IEEE 754 recognizes five kinds of floating-point
  341.        exceptions, listed below in declining order of probable importance.
  342.  
  343.        EExxcceeppttiioonn           DDeeffaauulltt RReessuulltt
  344.  
  345.        Invalid Operation   NaN or FALSE
  346.  
  347.        Overflow            +_Infinity
  348.  
  349.        Divide by Zero      +_Infinity
  350.  
  351.        Inexact             Rounded value
  352.  
  353.        NOTE:  An exception is not an error unless handled badly.  What
  354.        makes a class of exceptions exceptional is that no single default
  355.        response can be satisfactory in every instance.  On the other hand,
  356.        if a default response will serve most instances satisfactorily, the
  357.        unsatisfactory instances cannot justify aborting computation every
  358.        time the exception occurs.
  359.  
  360.  
  361.      For each kind of floating-point exception, IEEE 754 provides a flag
  362.      that is raised each time its exception is signaled, and stays raised
  363.      until the program resets it.  Programs may also test, save and restore
  364.      a flag.  Thus, IEEE 754 provides three ways by which programs can
  365.      handle exceptions for which the default result might be
  366.      unsatisfactory:
  367.  
  368.      1. Test for a condition that might cause an exception later, and
  369.         branch to avoid the exception.
  370.  
  371.      2. Test a flag to see if an exception has occurred since the program
  372.         last reset its flag.
  373.  
  374.      3. Test a result to see if it is a value that only an exception could
  375.         have produced.
  376.  
  377.  
  378.      CAUTION: The only reliable ways to discover if underflow has occurred
  379.      are to test if products or quotients lie closer to zero than the
  380.      underflow threshold, or to test the Underflow flag.  (Sums and
  381.      differences cannot underflow in IEEE 754; if xx !!== yy, then xx--yy is
  382.      correct to full precision and certainly nonzero regardless of how tiny
  383.      it may be.)
  384.  
  385.  
  386.      Products and quotients that underflow gradually can lose accuracy
  387.      gradually without vanishing, so comparing them with zero (as one might
  388.      on a VAX) will not reveal the loss.  Fortunately, if a gradually
  389.      underflowed value is destined to be added to something bigger than the
  390.      underflow threshold, as is almost always the case, digits lost to
  391.      gradual underflow will not be missed because they would have been
  392.      rounded off anyway.  So gradual underflows are usually _p_r_o_v_a_b_l_y
  393.      ignorable.  The same cannot be said of underflows flushed to 0.
  394.  
  395.      At the option of an implementor conforming to IEEE 754, other ways to
  396.      cope with exceptions may be provided:
  397.  
  398.      1. ABORT.  This mechanism classifies an exception in advance as an
  399.         incident to be handled by means traditionally associated with
  400.         error-handling statements like OONN EERRRROORR GGOO TTOO .......  Different
  401.         languages offer different forms of this statement, but most share
  402.         the following characteristics:
  403.  
  404.         *  No means is provided to substitute a value for the offending
  405.            operation's result and resume computation from what may be the
  406.            middle of an expression.  An exceptional result is abandoned.
  407.  
  408.         *  In a subprogram that lacks an error-handling statement, an
  409.            exception causes the subprogram to abort within whatever program
  410.            called it, and so on back up the chain of calling subprograms
  411.            until an error-handling statement is encountered or the whole
  412.            task is aborted and memory is dumped.
  413.  
  414.      2. STOP.  This mechanism, requiring an interactive debugging
  415.         environment, is more for the programmer than the program.  It
  416.         classifies an exception in advance as a symptom of a programmer's
  417.         error; the exception suspends execution as near as it can to the
  418.         offending operation so that the programmer can look around to see
  419.         how it happened.  Quite often the first several exceptions turn out
  420.         to be quite unexceptionable, so the programmer should be able to
  421.         resume execution after each one as if execution had not been
  422.         stopped.
  423.  
  424.      Ideally, each elementary function should act as if it were
  425.      indivisible, or atomic, in the following sense:
  426.  
  427.      * No exception should be signaled that is not deserved by the data
  428.        supplied to that function.
  429.  
  430.      * Any exception signaled should be identified with that function
  431.        rather than with one of its subroutines.
  432.  
  433.      * The internal behavior of an atomic function should not be disrupted
  434.        when a calling program changes from one to another of the five or so
  435.        ways of handling exceptions listed above, although the definition of
  436.        the function may be correlated intentionally with exception
  437.        handling.
  438.  
  439.      Ideally, every programmer should be able _c_o_n_v_e_n_i_e_n_t_l_y to turn a
  440.      debugged subprogram into one that appears atomic to its users.  But
  441.      simulating all three characteristics of an atomic function is still a
  442.      tedious affair, entailing hosts of tests and saves/restores.
  443.  
  444.      Meanwhile, the functions in lliibbmm are only approximately atomic.  They
  445.      signal no inappropriate exception except (possibly) oovveerrffllooww or
  446.      uunnddeerrffllooww when a result, if properly computed, might have lain barely
  447.      within range, and inexact in ccaabbss, ccbbrrtt, hhyyppoott, lloogg1100 and ppooww when it
  448.      happens to be exact, thanks to cancellation of errors.
  449.  
  450.      Otherwise, IInnvvaalliidd OOppeerraattiioonn is signaled only when any result but NaN
  451.      would probably be misleading.  OOvveerrffllooww is signaled only when the
  452.      exact result would be finite but beyond the overflow threshold.
  453.      DDiivviiddee--bbyy aa ffuunnccttiioonn takes exactly infinite values at finite operands.
  454.      UUnnddeerrffllooww is signaled only when the exact result would be nonzero but
  455.      tinier than the underflow threshold.  IInneexxaacctt is signaled only when
  456.      greater range or precision would be needed to represent the exact
  457.      result.
  458.  
  459.    EExxcceeppttiioonnss
  460.      The exception enables and the flags that are raised when an exception
  461.      occurs (as well as the rounding mode), are in the floating-point
  462.      control and status register.  This register can be read or written by
  463.      the routines described on ffppcc(3C).  This register's layout is
  464.      described in the file <<ssyyss//ffppuu..hh>>.
  465.  
  466.      A useful set of ``user trap handlers'' is available.  See ssiiggffppee(3C).
  467.  
  468.      The raw interface to the hardware registers is only intended to be
  469.      used by the code to implement IEEE user trap handlers.  IEEE
  470.      floating-point exceptions are enabled by setting the enable bit for
  471.      that exception in the floating-point control and status register.  If
  472.      an exception then occurs the UNIX signal SSIIGGFFPPEE is sent to the
  473.      process.  It is up to the signal handler to determine the instruction
  474.      that caused the exception and to take the action specified by the
  475.      user.
  476.  
  477.      The instruction that caused the exception is in one of two places.  If
  478.      the floating-point board is used (the floating-point implementation
  479.      revision register indicates this in its implementation field) then the
  480.      instruction that caused the exception is in the floating-point
  481.      exception instruction register.  In all other implementations the
  482.      instruction that caused the exception is at the address of the program
  483.      counter as modified by the branch delay bit in the cause register.
  484.      Both the program counter and cause register are in the sigcontext
  485.      structure passed to the signal handler (see ssiiggnnaall(2)).
  486.  
  487.      If the program is to be continued past the instruction that caused the
  488.      exception, the program counter in the signal context must be advanced.
  489.      If the instruction is in a branch delay slot then the branch must be
  490.      emulated to determine if the branch is taken and then the resulting
  491.      program counter can be calculated (see eemmuullaattee__bbrraanncchh(3X) and
  492.      ssiiggnnaall(2)).
  493.  
  494.      On systems using the R8000 processor, floating point exceptions are
  495.      generally fatal when trapped unless the process is being run in
  496.      precise exception mode.
  497.  
  498. PPLLAATTFFOORRMM SSPPEECCIIFFIICC LLIIBBRRAARRIIEESS
  499.      When compiling with --nn3322 or --6644, each processor has specially tuned,
  500.      hardware-specific versions of lliibbmm and lliibbffaassttmm that the run-time
  501.      linker will use, by default, whenever available.
  502.  
  503.      The R10000 tuned libraries are found in the directories:
  504.  
  505.           /usr/lib32/mips4/r10000/
  506.           /usr/lib64/mips4/r10000/
  507.  
  508.      The R8000 tuned libraries are found in the directories:
  509.  
  510.           /usr/lib32/mips4/r8000/
  511.           /usr/lib64/mips4/r8000/
  512.  
  513.      The R5000 tuned libraries are found in the directories:
  514.  
  515.           /usr/lib32/mips4/
  516.           /usr/lib64/mips4/
  517.  
  518.      And the R4000 tuned libraries are found in the directories:
  519.  
  520.           /usr/lib32/mips3/
  521.           /usr/lib64/mips3/
  522.  
  523.      At runtime, each program automatically uses the "best" library for the
  524.      system on which it is executing. For example, if the executing program
  525.      is a MIPS3 program designed to run on an r4000 processor, it will
  526.      still use the MIPS4 R10000-tuned math library when running on an
  527.      r10000 system.
  528.  
  529. BBUUGGSS
  530.      When signals are appropriate, they are emitted by certain operations
  531.      within the codes so a subroutine trace may be needed to identify the
  532.      function with its signal. And the codes all take the IEEE 754 defaults
  533.      for granted; this means that a decision to trap all divisions by zero
  534.      could disrupt a code that would otherwise get correct results despite
  535.      division by zero.
  536.  
  537. SSEEEE AALLSSOO
  538.      ssiiggnnaall(2), ffppcc(3C), eemmuullaattee__bbrraanncchh(3X), ssiiggffppee(3C), mmaatthheerrrr(3M)
  539.  
  540.      This man page is available only online.
  541.